package com.jincheng.controller;

import com.jincheng.module.User;
import com.jincheng.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户信息")
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation(value = "添加用户", notes = "添加用户,并返回用户信息")
    @PostMapping("/adduser")
    public User addUser(@RequestBody User user) {
        return userService.add(user);
    }

    @ApiOperation(value = "修改用户", notes = "修改用户信息,并返回修改后的用户信息")
    @PostMapping("/updateuser")
    public User update(User user) {
        return userService.update(user);
    }

    @ApiOperation(value = "查询用户", notes = "根据用户id查询用户信息")
    @ApiImplicitParam(name = "uid", dataType = "String", required = true)
    @GetMapping("/queryuser")
    public User queryById(String uid) {
        return userService.queryById(uid);
    }

    @ApiOperation(value = "删除用户", notes = "根据用户id删除用户信息")
    @ApiImplicitParam(name = "uid", required = true)
    @DeleteMapping("/deleteuser")
    public String delete(String uid) {
        return userService.delete(uid);
    }
}
